package service.impl;

import dao.GoodsDAO;
import dao.impl.GoodsDAOImpl;
import pojo.Goods;
import service.GoodsService;

import java.util.List;

/**
 * @author CaiKe lq
 * @create 2021/1/9
 */
public class GoodsServiceImpl implements GoodsService {

    private GoodsDAO goodsDAO = new GoodsDAOImpl();

    @Override
    public boolean addGoods(Goods goods) {
        Integer integer = goodsDAO.addGoods(goods);
        return integer == 1;
    }

    @Override
    public boolean deleteGoods(int id) {
        Integer integer = goodsDAO.deleteGoodsById(id);
        return integer == 1;
    }

    @Override
    public boolean portGoods(int id, int num) {
        Integer integer = goodsDAO.portGoods(id, num);
        return integer==1;
    }

    @Override
    public boolean updateGoods(Goods goods) {
        Integer integer = goodsDAO.updateGoods(goods);
        return  integer==1;
    }

    @Override
    public List<Goods> queryAllGoods(int aimId, int chose) {
        return goodsDAO.queryAllGoods(aimId, chose);
    }

    @Override
    public List<Goods> queryAllGoods() {
        return goodsDAO.queryAllGoods();
    }

    @Override
    public Integer queryGoodsNumById(int id) {
        return goodsDAO.queryGoodsNumById(id);
    }

    @Override
    public Goods queryGoodsById(int id) {
        return goodsDAO.queryGoodsById(id);
    }

    @Override
    public Integer queryForGoodsNum() {
        return goodsDAO.queryForGoodsNum();
    }

    @Override
    public List<Goods> queryLatestGoods(int num) {
        return goodsDAO.queryLatestGoods(num);
    }
}